/*
 * PhysicWorld.hpp
 * This file is part of FunBall 
 *
 * Copyright (C) 2012 - Francois Berder
 *
 * FunBAll is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * FunBAll is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */



#ifndef __PHYSICWORLD_HPP__
#define __PHYSICWORLD_HPP__

#include <Box2D/Box2D.h>
#include "PhysicObject.hpp"

class PhysicWorld
{
    friend PhysicObject;

    public :
    
        static PhysicWorld& instance();
        
        void createWorld();
        void destroyWorld();
        
        PhysicObject& createObject(const json::Object& data);

        b2World* world();
        
        void update(const float dt);
        
    private :
    
        PhysicWorld();
        PhysicWorld(const PhysicWorld& pw);
        ~PhysicWorld();
        
        PhysicWorld& operator=(const PhysicWorld& pw);

        b2World *m_world;
};

#define GET_PHYSIC_WORLD PhysicWorld::instance().world()
#define BOX2D_TO_SFML 30.f
#define SFML_TO_BOX2D 1.f/BOX2D_TO_SFML

inline PhysicObject& CREATE_PHYSIC_OBJECT(const json::Object& data);

#endif /* __PHYSICWORLD_HPP__ */

